import java.util.Arrays;
import java.util.List;

public class project {
    public int countPairs(int[] nums, int k) {
        int ret=0;
        for(int i=0;i<nums.length-1;i++){
            for(int j=i+1;j<nums.length;j++){
                if(nums[i]==nums[j]&&i*j%k==0){
                    ret++;
                }
            }
        }
        return ret;
    }

















    public boolean isOneBitCharacter(int[] bits) {
        int len=bits.length;
        int index=0;
        while (index<len-1){
            index+=bits[index]+1;
        }
        return index==len-1;
    }
}












class ListNode {
    int val;
    ListNode next;
    ListNode() {}
    ListNode(int val) { this.val = val; }
    ListNode(int val, ListNode next) { this.val = val; this.next = next; }
}
class Solution {
    public ListNode mergeNodes(ListNode head) {
        ListNode newHead=new ListNode(-1);
        ListNode cur=head;
        ListNode prev=newHead;
        int sum=0;
        while (cur!=null){
            if(cur.val==0){
                if(sum!=0){
                    prev.next=new ListNode(sum);
                    prev=prev.next;
                    sum=0;
                }
            }
            sum+=cur.val;
            cur=cur.next;
        }
        return newHead.next;
    }
}